package com.huawei.hms.push.c;

import com.huawei.hms.support.log.HMSLog;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

public class d {
    public static String a(JSONObject jSONObject, String str, String str2) {
        if (jSONObject != null) {
            try {
                if (jSONObject.has(str)) {
                    str2 = jSONObject.getString(str);
                }
            } catch (JSONException e) {
                HMSLog.w("RemoteMessageResolve", "JSONException: get " + str + " error.");
            }
        }
        return str2;
    }

    public static int a(JSONObject jSONObject, String str, int i) {
        if (jSONObject != null) {
            try {
                if (jSONObject.has(str)) {
                    i = jSONObject.getInt(str);
                }
            } catch (JSONException e) {
                HMSLog.w("RemoteMessageResolve", "JSONException: get " + str + " error.");
            }
        }
        return i;
    }

    public static String[] a(JSONObject jSONObject, String str, String[] strArr) {
        String[] strArr2 = null;
        if (jSONObject == null) {
            return null;
        }
        try {
            if (!jSONObject.has(str)) {
                return null;
            }
            JSONArray jSONArray = jSONObject.getJSONArray(str);
            String[] strArr3 = new String[jSONArray.length()];
            int i = 0;
            while (i < jSONArray.length()) {
                try {
                    strArr3[i] = (String) jSONArray.get(i);
                    i++;
                } catch (JSONException e) {
                    strArr2 = strArr3;
                }
            }
            return strArr3;
        } catch (JSONException e2) {
            HMSLog.w("RemoteMessageResolve", "JSONException: get " + str + " error.");
            return strArr2;
        }
    }
}
